﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI.WebControls;
using QuantumServices.MailService;

namespace QuantumServices
{
    /// <summary>
    /// A class providing SMTP utilities
    /// </summary>
    public class MailUtils
    {
        public static void SendMailFromKlowdi(string strSender, string strMessage, string strDestinationMail, string strSubject)
        {
            System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();
            message.From = strSender;
            message.To = strDestinationMail;
            message.Subject = strSubject;
            message.Body = strMessage;
            System.Web.Mail.SmtpMail.SmtpServer = "smtp.klowdi.com";
            System.Web.Mail.SmtpMail.Send(message);
        }

        public static void SendMail<T>(string strDestinationMail, string strSubject) where T : AbstractMailMessage, new()
        {
            T aMailMessage = new T();
            SendMailFromKlowdi(aMailMessage.Sender, aMailMessage.MessageBody, strDestinationMail, strSubject);
        }

        public static void SendMail<T>(T aMailMessage, string strDestinationMail) where T : AbstractMailMessage, new()
        {
            SendMailFromKlowdi(aMailMessage.Sender, aMailMessage.MessageBody, strDestinationMail, aMailMessage.Subject);
        }

    }
}